<?php
/**
 * 友情链接
 */
class Link_Model extends Model {
	
	public function __construct() {
		parent::__construct();	
		$this->setTable('#@_link', 'id');
	}
	
	public function getTotal($where) {
		$res = $this->db->table('#@_link')
				->field("COUNT(*) AS num")
				->where($where)
				->getOne();
		return $res['num'];
	}
	
	public function getAll($where, $limit = '0, 10', $order = 'id', $by = 'DESC') {
		$res = $this->db->table('#@_link')
			->where($where)
			->limit($limit)
			->order("$order $by")
			->getAll();
		foreach ($res as & $value) {
			$value['title'];
		}
		return $res;	
	}
}